#!/usr/bin/env bash
export SOURCE_CODE=/home/work/eplus
export SOURCE_CODE_WEB=/home/work/eplus-react
#mvn package 缩写
alias mp="mvn package -Dmaven.test.skip=true"
#mvn package 缩写
alias mpl="/home/work/eplus/doc/profile/mpl.sh"
#更新前端
alias upweb="cd $SOURCE_CODE_WEB \
    && echo ========拉取代码========= \
    && git pull \
    && echo ========安装依赖======== \
    && cnpm install \
    && echo ========编译项目======== \
    && npm run build  \
    && echo ========启动pm2服务======== \
    && npm run start:pm2 \
    && echo ========================"
#up >> update 缩写，完成拉取代码，maven打包命令
alias upall="cd $SOURCE_CODE \
    && echo =========停止全部服务===== \
    && ka \
    && echo ========拉取代码========= \
    && git pull \
    && echo ========maven 打包======== \
    && mp \
    && echo ========jar 包已更新======== \
    && echo rs xxx 重启 \
    && echo ========================"
#单独更新某个模块
alias up="/home/work/eplus/doc/profile/mpl.sh"
#ki all
alias ka="pkill  --signal 9 -f eplus"
alias ki="/home/work/eplus/doc/profile/ki.sh"
alias lg="/home/work/eplus/doc/profile/lg.sh"
alias rs="/home/work/eplus/doc/profile/rs.sh"
alias st="/home/work/eplus/doc/profile/st.sh"
alias eplus="ps -elf |grep eplus"
#启动最后微服务
alias stlast="st gateway && st admin && st customer && st file && st home && st building && st oa && st nb && st syncData && st jmp && st college"

#更新admin
alias upadmin="cd $SOURCE_CODE \
    && echo ========拉取代码========= \
    && git pull \
    && echo ========编译admin========= \
    && mvn package -pl eplus-admin/eplus-admin-biz -am -Dmaven.test.skip=true  \
    && rs admin"

#更新gateway
alias upgateway="cd $SOURCE_CODE \
    && echo ========拉取代码========= \
    && git pull \
    && echo ========编译gateway========= \
    && mvn package -pl eplus-gateway -am -Dmaven.test.skip=true  \
    && rs gateway"

#命令补全
#kill
complete -W 'nacos gateway admin building house customer file oa nb syncData jmp college' ki
#restart
complete -W 'nacos gateway admin building house customer file oa nb syncData jmp college' rs
#start
complete -W 'nacos gateway admin building house customer file oa nb syncData jmp college' st
#log
complete -W 'nacos gateway admin building house customer file oa nb syncData jmp college' lg
#up
complete -W 'building house customer file oa nb syncData jmp college' up

